<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page trimDirectiveWhitespaces="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <link href="resources/css/style.css" rel="stylesheet"/>
    <style type="text/css">
    .borderT td {
    	border: 1px solid #dddddd;
    }
    </style>
    
    <script type="text/javascript">
    $(function() {
    	$("td").css("text-align", "center");
    });
    
    function selectAd() {
    	var ad_no = $("input[name=ad_no]:checked").val();
    	var values = $("#ad_no_" + ad_no ).html();
    	values += " / " + $("#regdate_" + ad_no ).html();
    	values += " / " + $("#contents_title_" + ad_no ).html();
    	values += " / " + $("#service_" + ad_no ).html();
    	
    	if ( $("#paytype_" + ad_no ).html() != null && $("#paytype_" + ad_no ).html() != "" && $("#paytype_" + ad_no ).html() != "undefined" ) {
    		values += " / " + $("#paytype_" + ad_no ).html();
    	}
    	
    	$("input[name=ad_no]", opener.document ).val( ad_no );
    	$("#ad_lb", opener.document ).val( values );
    	self.close();
    }
    </script>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>꽁알 Administrator</title>
</head>
<body>
<br/>

<c:if test="${listSize > 0 }">
<table class="borderT" align="left" cellspacing="0" cellpadding="10" width="98%">
    <tr class="table_title">
        <td width="8%">선택</td>
        <td width="12%">광고번호</td>
        <td width="26%">등록날짜</td>
        <td width="25%">컨텐츠 Title</td>
        <td width="12%">카테고리</td>
        <td width="10%">선/후불</td>
    </tr>
</table>
<div style="height:300px; overflow:auto; clear:both;">
<table class="borderT" align="center" cellspacing="0" cellpadding="10">
    <c:forEach var="list" items="${adList }">
    <tr>
        <td width="8%"><input type="radio" name="ad_no" value="${list.ad_no }"/></td>
        <td width="12%" id="ad_no_${list.ad_no }">${list.ad_no }</td>
        <td width="26%" id="regdate_${list.ad_no }">${list.regdate }</td>
        <td width="25.5%" id="contents_title_${list.ad_no }">${list.contents_title }</td>
        <td width="12%">
            <c:if test="${list.service == 'ggong' }"><span id="service_${list.ad_no }">꽁게임</span></c:if>
            <c:if test="${list.service == 'time' }"><span id="service_${list.ad_no }">타임게임</span></c:if>
            <c:if test="${list.service == 'special' }"><span id="service_${list.ad_no }">스페셜게임</span></c:if>
        </td>
        <td width="9.5%">
            <c:if test="${list.paytype == 'beforePay' }"><span id="paytype_${list.ad_no }">선불제</span></c:if>
            <c:if test="${list.paytype == 'afterPay' }"><span id="paytype_${list.ad_no }">후불제</span></c:if>
        </td>
    </tr>
    </c:forEach>
</table>
</div>
<br/>
<table align="center" cellspacing="0" cellpadding="10">
	<tr>
        <td colspan="6">
            <input type="button" value="확인" style="width:80px;height:30px;" onclick="selectAd()"/>
        </td>
    </tr>
</table>

</c:if>
<table align="center" cellspacing="0" cellpadding="10">
<c:if test="${listSize <= 0 }">
    <tr>
        <td align="center">등록된 광고가 없습니다.</td>
    </tr>
    <tr>    
        <td align="center">
            <input type="button" value="닫기" onclick="self.close()"/>
        </td>
    </tr>
</c:if>
</table>

</body>
</html>